package com.intelligentclass.requestItem;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class HomeworkItem {
    private int hid;
    private int cid;
    private String hname;
    private LocalDateTime beginDate;
    private LocalDateTime endDate;
    private int totalNumber;
    private int subNumber;

    private int isCommit;
    private int fullGrade;

    public HomeworkItem() {}
    public HomeworkItem(int hid, int cid, String hname, LocalDateTime beginDate, LocalDateTime endDate, int fullGrade) {
        this.hid = hid;
        this.cid = cid;
        this.hname = hname;
        this.beginDate = beginDate;
        this.endDate = endDate;
        this.isCommit = 0;
        this.fullGrade = fullGrade;
    }

    public void setTotalNumber(int totalNumber) {
        this.totalNumber = totalNumber;
    }
    public void setSubNumber(int subNumber) {
        this.subNumber = subNumber;
    }
    public void setIsCommit(int isCommit) {
        this.isCommit = isCommit;
    }

    public String toString(){
        StringBuilder sb = new StringBuilder();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        sb.append("{");
        sb.append("\"hid\":").append(hid).append(",");
        sb.append("\"cid\":").append(cid).append(",");
        sb.append("\"hname\":\"").append(hname).append("\",");
        sb.append("\"beginDate\":\"").append(beginDate.format(formatter)).append("\",");
        sb.append("\"endDate\":\"").append(endDate.format(formatter)).append("\",");
        sb.append("\"totalNumber\":").append(totalNumber).append(",");
        sb.append("\"subNumber\":").append(subNumber).append(",");
        sb.append("\"isCommit\":").append(isCommit == 1 ? "true" : "false").append("}");
        return sb.toString();
    }

    public int getHid(){
        return hid;
    }
    public void setHid(int hid){
        this.hid = hid;
    }
    public int getCid() {
        return cid;
    }
    public void setCid(int cid) {
        this.cid = cid;
    }
    public String getHname() {
        return hname;
    }
    public void setHname(String hname) {
        this.hname = hname;
    }
    public LocalDateTime getBeginDate() {
        return beginDate;
    }
    public void setBeginDate(LocalDateTime beginDate) {
        this.beginDate = beginDate;
    }
    public LocalDateTime getEndDate() {
        return endDate;
    }
    public void setEndDate(LocalDateTime endDate) {
        this.endDate = endDate;
    }
    public int getTotalNumber() {
        return totalNumber;
    }
    public int getSubNumber() {
        return subNumber;
    }
    public int getIsCommit() {
        return isCommit;
    }

    public int getFullGrade() {
        return fullGrade;
    }

    public void setFullGrade(int fullGrade) {
        this.fullGrade = fullGrade;
    }
}
